define(function(require, exports, module) {
	"require:nomunge,exports:nomunge,module:nomunge";
	
	//百度地图模块
require("http://api.map.baidu.com/getscript?v=2.0&ak=8faf9732a49d424a7fb0b4a252eb7fd4&services=&t=20141124175808");

	/**
	 * 加载地图
	 */
exports.allmap=function(id,latitude,longitude,address) {

		 if(latitude=="")
				latitude = 34.647653;
			
			if(longitude=="")
				longitude = 112.418722;
				
			// 百度地图API功能
			var map = new BMap.Map(id);            // 创建Map实例
			map.centerAndZoom(new BMap.Point(longitude,latitude),16);  //初始化时，即可设置中心点和地图缩放级别。
			var point = new BMap.Point(longitude, latitude); // 创建点坐标  
			var myMarker = new BMap.Marker(point);
			map.addOverlay(myMarker);

			if(typeof address != "undefined"){
				
				var myGeo = new BMap.Geocoder();
				myGeo.getPoint(address, function(point) {
					if (point) {
						myMarker = new BMap.Marker(point);
						map.centerAndZoom(point, 12);
						map.addOverlay(myMarker);
						
						//当地图移动时，获取屏幕中间点的坐标
						var center = map.getCenter();    
//						alert("地图中心点变更为：" + center.lng + ", " + center.lat);  
						document.getElementById("input-longitude").value = center.lng;
						document.getElementById("input-latitude").value = center.lat;
					}
				}, "全国");
				
				
				
			}
		
			
			map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
			map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));  //右上角，仅包含平移和缩放按钮
			map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));  //左下角，仅包含平移按钮
			map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮

			map.addEventListener("click", function(e) {//地图单击事件
				if (myMarker != null) {
					map.removeOverlay(myMarker);
				}
				document.getElementById("input-longitude").value = e.point.lng;
				document.getElementById("input-latitude").value = e.point.lat;
				point = new BMap.Point(e.point.lng, e.point.lat);
				myMarker = new BMap.Marker(point);
				map.addOverlay(myMarker);
			});
		
	}
});